package com.liuzy.crawler;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.wb.swt.SWTResourceManager;

import com.liuzy.crawler.core.Command;

/**
 * @author liuzy
 * @since 2015年9月23日
 */
public class About {
	static Shell about;
	static Label name;
	static Label author;
	static Label qq;
	static Label email;
	static Label url;
	private static Label lblesc;
	/**
	 * @wbp.parser.entryPoint
	 */
	static void show(Shell shell) {
		about = new Shell(shell, SWT.PRIMARY_MODAL);
		about.setSize(400, 300);
		about.setText("设置");
		about.setLocation(shell.getLocation().x + about.getSize().x / 2, shell.getLocation().y + about.getSize().y / 2);

		Composite cpWeb = new Composite(about, SWT.NONE);
		cpWeb.setBounds(238, 23, 150, 150);
		cpWeb.setBackgroundImage(SWTResourceManager.getImage(About.class, "web.png"));
		cpWeb.setToolTipText("查看项目源代码");
		cpWeb.addListener(SWT.MouseDown, new Listener() {
			@Override
			public void handleEvent(Event e) {
				Command.openBrowser("https://git.oschina.net/liuzy1988/Crawler");
			}
		});

		name = new Label(about, SWT.NONE);
		name.setFont(SWTResourceManager.getFont("Microsoft YaHei UI", 12, SWT.NORMAL));
		name.setBounds(38, 29, 168, 25);
		name.setText("名称：Crawler");

		author = new Label(about, SWT.NONE);
		author.setText("作者：刘仲阳");
		author.setFont(SWTResourceManager.getFont("Microsoft YaHei UI", 12, SWT.NORMAL));
		author.setBounds(38, 83, 168, 25);

		qq = new Label(about, SWT.NONE);
		qq.setText("QQ：416657468");
		qq.setToolTipText("QQ联系我");
		qq.setFont(SWTResourceManager.getFont("Microsoft YaHei UI", 12, SWT.NORMAL));
		qq.setBounds(38, 137, 168, 25);
		qq.addMouseListener(new MouseListener() {
			@Override
			public void mouseUp(MouseEvent e) {
				Command.openBrowser("http://wpa.qq.com/msgrd?v=3&uin=416657468&site=www.liuzhongyang.com&menu=yes");
			}
			@Override
			public void mouseDown(MouseEvent e) {
			}
			@Override
			public void mouseDoubleClick(MouseEvent e) {
			}
		});

		email = new Label(about, SWT.NONE);
		email.setText("yjwkhhbj1988@163.com");
		email.setToolTipText("发邮件联系我");
		email.setFont(SWTResourceManager.getFont("Microsoft YaHei UI", 12, SWT.NORMAL));
		email.setBounds(41, 191, 194, 25);
		email.addMouseListener(new MouseListener() {
			@Override
			public void mouseUp(MouseEvent e) {
				Command.openBrowser("mailto:" + email.getText());
			}
			@Override
			public void mouseDown(MouseEvent e) {
			}
			@Override
			public void mouseDoubleClick(MouseEvent e) {
			}
		});

		url = new Label(about, SWT.NONE);
		url.setText("http://www.liuzhongyang.com/Crawler");
		url.setToolTipText("打开软件官网");
		url.setFont(SWTResourceManager.getFont("Microsoft YaHei UI", 12, SWT.NORMAL));
		url.setBounds(38, 245, 311, 25);
		url.addListener(SWT.MouseDown, new Listener() {
			@Override
			public void handleEvent(Event e) {
				Command.openBrowser("http://www.liuzhongyang.com/Crawler/");
			}
		});

		lblesc = new Label(about, SWT.NONE);
		lblesc.setText("按ESC退出");
		lblesc.setBounds(340, 0, 58, 17);

		about.open();
	}
}
